// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 获取字典页树结构 GET /api/dict/tree */
export async function queryDictTree(options?: { [key: string]: any }) {
  return request<API.TreeNodeItem[]>('/api/dicttype/tree', {
    method: 'GET',
    ...(options || {}),
  });
}


/** 获取字典 */
export async function queryAllDict(options?: { [key: string]: any }) {
  return request<API.TreeNodeItem[]>('/api/dictdata', {
    method: 'GET',
    ...(options || {}),
  });
}


/** 根据类型获取字典 GET /api/dict/${param0} */
export async function queryDictByType(
  params: {
    // path
    /** 字典类型 */
    type: string;
  },
  options?: { [key: string]: any },
) {
  const { type: param0, ...queryParams } = params;
  return request<API.DictItem[]>(`/api/dict/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** 获取字典列表 GET /api/dict */
export async function queryDict(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 字典类型id */
    typeId?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RequestData>('/api/dict', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 更新字典 PUT /api/dict */
export async function updateDict(body: API.DictItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/dict', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 添加字典 POST /api/dict */
export async function addDict(body: API.DictItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/dict', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除字典 DELETE /api/dict */
export async function removeDict(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/dict', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}


/** 删除字典 DELETE /api/dict */
export async function batchRemoveDict(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/dict/batchdel', {
    method: 'DELETE',
    params: {
      ...options,
    },
    ...(options || {}),
  });
}

export async function validCode(params: any) {
  return request('/api/validDicCode', {
    params,
  });
}